#include <iostream>

std::string 
censor_string1(std::string text, const std::string& remove)
{
  std::size_t pos = 0;
  std::size_t found;
  std::string res;

  while (true)
    {
      found = text.find(remove, pos);

      if (found == std::string::npos)
	{
	  res += text.substr(pos);
	  break;
	}

      res += text.substr(pos, found - pos);
      pos = found + remove.length();
    }

  return res;
}

void 
censor_string2(std::string& text, const std::string& remove)
{
  while (true)
    {
      std::size_t found = text.find(remove);
      if (found == std::string::npos)
	{
	  break;
	}
      
      text.erase(found, remove.length());
    }
}


int main()
{
  std::string original_string = "taStanford Universita";
  std::string remove_pattern = "ta";

  /*std::cout << "Enter a string: ";
  std::cin >> original_string;
  std::cout << "Enter the remove pattern: ";
  std::cin >> remove_pattern;*/

  std::string result = censor_string1(original_string, remove_pattern);
  std::cout << "Remove with censor_string1. result = " << result << std::endl;

  censor_string2(original_string, remove_pattern);
  std::cout << "Remove with censor_string2. result = " << original_string << std::endl;
}
